package com.xmb.wechat.view.alipay;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.xmb.wechat.R;
import com.xmb.wechat.R2;
import com.xmb.wechat.application.WechatStartApplication;
import com.xmb.wechat.base.BaseActivity;
import com.xmb.wechat.bean.WechatContactBean;
import com.xmb.wechat.bean.WechatContactBean_;
import com.xmb.wechat.entity.AliPayGatheringEntity;
import com.xmb.wechat.util.PicLoadUtils;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * @Author lijiangop
 * @CreateTime 2020/5/28 10:11
 */
public class AliPayTransferDetailActivity extends BaseActivity {
    @BindView(R2.id.iv_avatar)
    ImageView    mIvAvatar;
    @BindView(R2.id.tv_avatar)
    TextView     mTvAvatar;
    @BindView(R2.id.tv_money)
    TextView     mTvMoney;
    @BindView(R2.id.tv_trade_state)
    TextView     mTvTradeState;
    @BindView(R2.id.tv_gathering_way_tag)
    TextView     mTvGatheringWayTag;
    @BindView(R2.id.tv_gathering_way)
    TextView     mTvGatheringWay;
    @BindView(R2.id.tv_gathering_reason)
    TextView     mTvGatheringReason;
    @BindView(R2.id.tv_opposite_account)
    TextView     mTvOppositeAccount;
    @BindView(R2.id.tv_set_up_time)
    TextView     mTvSetUpTime;
    @BindView(R2.id.ll_more)
    LinearLayout mLlMore;
    @BindView(R2.id.tv_order_num)
    TextView     mTvOrderNum;
    @BindView(R2.id.ll_order_num)
    LinearLayout mLlOrderNum;
    @BindView(R2.id.tv_bill_type)
    TextView     mTvBillType;
    @BindView(R2.id.tv_tag_remark)
    TextView     mTvTagRemark;
    @BindView(R2.id.ll_complain)
    LinearLayout mLlComplain;

    public AliPayTransferDetailActivity() {
        super(R.layout.activity_alipay_transfer_detail);
        isChangeStatusBarTxtColor = false;
    }

    public static void start(Activity activity, AliPayGatheringEntity entity, String realName) {
        Intent intent = new Intent(activity, AliPayTransferDetailActivity.class);
        intent.putExtra("data", entity);
        intent.putExtra("realName", realName);
        activity.startActivity(intent);
    }

    @Override
    protected void initView() {
        setStatusBarColor(Color.parseColor("#b0b0b0"));
        setNavigationColor(Color.parseColor("#ffffff"));

        AliPayGatheringEntity entity = (AliPayGatheringEntity) getIntent().getSerializableExtra("data");
        if (entity == null)
            return;
        //showView
        //头像
        WechatContactBean unique = WechatStartApplication.getBoxStore().boxFor(WechatContactBean.class).query()
                .equal(WechatContactBean_.id, entity.getPayerId()).build().findUnique();
        if (unique != null) {
            PicLoadUtils.setupRoundPicIntoImageView(unique.getAvatarSrc(), unique.getAvatar(), mIvAvatar);
        }
        //账号
        String realName = getIntent().getStringExtra("realName");
        mTvAvatar.setText(TextUtils.isEmpty(realName) ? "" : realName);

        //金额
        mTvMoney.setText(TextUtils.isEmpty(entity.getMoney()) ? "" : (entity.isReceived() ? "+" : "-") + entity.getMoney());
        mTvTradeState.setText(TextUtils.isEmpty(entity.getTradeState()) ? "" : entity.getTradeState());
        mTvTradeState.setTextColor(entity.getState() == 0 ? Color.parseColor("#f9840d") : getResources().getColor(R.color.black_60));

        //收款方式
        mLlComplain.setVisibility(entity.isReceived() ? View.GONE : View.VISIBLE);
        mTvGatheringWayTag.setText(entity.isReceived() ? "收款方式" : "付款方式");
        mTvGatheringWay.setText(TextUtils.isEmpty(entity.getGatheringWay()) ? "" : entity.getGatheringWay());

        mTvGatheringReason.setText(TextUtils.isEmpty(entity.getReason()) ? "" : entity.getReason());
        mTvOppositeAccount.setText(TextUtils.isEmpty(entity.getPayerAccount()) ? "" : entity.getPayerAccount());
        mTvSetUpTime.setText(TextUtils.isEmpty(entity.getTime()) ? "" : entity.getTime());
        mTvOrderNum.setText(TextUtils.isEmpty(entity.getOrderNum()) ? "" : entity.getOrderNum());
        mTvBillType.setText(TextUtils.isEmpty(entity.getBillType()) ? "" : entity.getBillType());
    }


    @OnClick(R2.id.ll_more)
    public void onViewClicked() {
        mLlMore.setVisibility(View.GONE);
        mLlOrderNum.setVisibility(View.VISIBLE);
    }
}
